package org.op.service.doc;

import java.awt.Color;
import java.util.HashMap;
import java.util.Map;

import javax.swing.text.AttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;

import org.op.service.config.ConfigKeys;
import org.op.service.config.ConfigurationService;

/**
 *  Defines the styles for the different element types of the editor document object
 * 
 * @author david.peters
 *
 */
public class StyleSets {

	public static final String CONTENT_SET = "content";
	public static final String HTML_SET = "html";
	
	private Map<String, AttributeSet> styles;
	private ConfigurationService configService;
	
	public StyleSets() {
	}
	
	public void init() {
		styles = new HashMap<String, AttributeSet>();
		
		String standardFontFamily = configService.getProperty(ConfigKeys.STYLE_FONT_FAMILY);
		String standardFontSize = configService.getProperty(ConfigKeys.STYLE_FONT_SIZE);
		//String linkFontColor = configService.getProperty(ConfigKeys.STYLE_LINK_COLOR);
		//String standardFontColor = configService.getProperty(ConfigKeys.STYLE_STANDARD_FONT_COLOR);
		//String backgroundColor = configService.getProperty(ConfigKeys.EDITOR_BG_COLOR);
		
        SimpleAttributeSet sas = new SimpleAttributeSet();
        StyleConstants.setFontFamily(sas, standardFontFamily);
        StyleConstants.setFontSize(sas, new Integer(standardFontSize));
        //StyleConstants.setForeground(sas, Color.getColor(standardFontColor));
        //StyleConstants.setBackground(sas, Color.getColor(backgroundColor));
        styles.put(CONTENT_SET, sas);
        
        SimpleAttributeSet htsas = new SimpleAttributeSet();
        StyleConstants.setFontFamily(htsas, standardFontFamily);
        StyleConstants.setFontSize(htsas, new Integer(standardFontSize));
        StyleConstants.setItalic(htsas, true);
        //StyleConstants.setUnderline(htsas, true);
        StyleConstants.setForeground(htsas, Color.BLUE);
        //StyleConstants.setForeground(htsas, Color.getColor(linkFontColor));
        
        styles.put(HTML_SET, htsas);
	}
	
	public AttributeSet getSet(String key) {
		return styles.get(key);
	}

	public ConfigurationService getConfigService() {
		return configService;
	}

	public void setConfigService(ConfigurationService configService) {
		this.configService = configService;
	}
	
}
